home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 23 / AMIGAplus Sonderheft 23 (2000)(Falke)(DE)[!].iso / Tools / Text-Viewer / MSWordView / mswordview_src / piecetable.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-11-06  |  1.5 KB  |  56 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include "config.h"
  6. #include "mswordview.h"
  7.  
  8. extern FILE *erroroutput;
  9.  
  10. int get_piecetable(FILE *in,U32 **rgfc,U32 **avalrgfc,U16 **sprm,U32 *clxcount)
  11.     {
  12.     U32 lcb;
  13.     int nopieces=0;
  14.     int i;
  15.     U32 aval;
  16.  
  17.     lcb = read_32ubit(in);
  18.     (*clxcount)+=(lcb+4);
  19.     nopieces = (lcb-4)/12;
  20.     error(erroroutput,"lcb is %ld, theres %d pieces\n",lcb,nopieces);
  21.     
  22.     *rgfc = (U32 *) malloc((nopieces +1) * sizeof(U32));
  23.     *avalrgfc = (U32 *) malloc((nopieces) * sizeof(U32));
  24.     *sprm = (U16 *)  malloc((nopieces) * sizeof(U16));
  25.  
  26.     if ( ((*rgfc) == NULL) || ((*avalrgfc) == NULL) || ((*sprm) == NULL) )
  27.         {
  28.         error(erroroutput,"aborting due lack to lack of memory\n");
  29.         exit(-1);
  30.         }
  31.  
  32.     for(i=0;i<nopieces+1;i++)
  33.         {
  34.         (*rgfc)[i] = read_32ubit(in);
  35.         error(erroroutput," array entry is %x\n",(*rgfc)[i]);
  36.         }
  37.  
  38.     for(i=0;i<nopieces;i++)
  39.         {
  40.         aval = read_16ubit(in);
  41.         (*avalrgfc)[i] = read_32ubit(in);
  42.         error(erroroutput,"mpiece: current piece is %d file offsets of pieces are (%x)\n",i,(*avalrgfc)[i]);
  43.         error(erroroutput,"mpiece: end of pieces is (%x)\n",(*avalrgfc)[i]+(*rgfc)[i+1]-(*rgfc)[i]);
  44.         (*sprm)[i] = read_16ubit(in);
  45.         error(erroroutput,"TOUGH: the sprm referenced here is %d\n",(*sprm)[i]);
  46.         if ((*sprm)[i] & 0x01)
  47.             error(erroroutput,"sprm varient 2\n");
  48.         else
  49.             {
  50.             error(erroroutput,"sprm varient 1, isprm is %x, val is %d\n",((*sprm)[i]&0x00fe)>>1,((*sprm)[i]&0xff00)>>8);
  51.             }
  52.         }
  53.     error(erroroutput,"NOPIECES is %d\n",nopieces);
  54.     return(nopieces);
  55.     }
  56.